// 账目类
class Record {
    private String date;
    private String type; // "收入" 或 "支出"
    private String category;
    private double amount;
    private String description;

    public Record(String date, String type, String category, double amount, String description) {
        this.date = date;
        this.type = type;
        this.category = category;
        this.amount = amount;
        this.description = description;
    }

    public String getDate() { return date; }
    public String getType() { return type; }
    public String getCategory() { return category; }
    public double getAmount() { return amount; }
    public String getDescription() { return description; }

    @Override
    public String toString() {
        return date + "," + type + "," + category + "," + amount + "," + description;
    }

    public static Record fromString(String line) {
        String[] parts = line.split(",");
        if (parts.length != 5) return null;
        try {
            return new Record(parts[0], parts[1], parts[2], Double.parseDouble(parts[3]), parts[4]);
        } catch (NumberFormatException e) {
            return null;
        }
    }
}
